python PCL LAS Open3D点云
2023/03/18 23:54:34
VS2019+PCL+LAS点云学习
点云安装
安装教程
- CSDN教程等
1.1 【python3.6】python安装PCL(适用命令行或pycham中)-PCL 1.12.1
https://blog.csdn.net/weixin_44244190/article/details/124324121
1.
- 部分教程
2.1 点云可视化:mayavi、matplotlib、CloudCompare
2.2 点云数据常用处理:数据集增强(仿射变换、添加噪声、下采样、数据标准化)
2.3 Python点云数据处理
2.4【点云无损压缩】python-pcl:点云las、laz文件的读取、写入、压缩
点云入门
功能示例代码段
- 读取点云及基本信息
def readlas():
with laspy.open('./data/10层3号切片抽稀.las') as fh:
print('Points from Header:', fh.header.point_count)
las = fh.read()
print(las)
print('Points from data:', len(las.points))
ground_pts = las.classification == 2
bins, counts = np.unique(las.return_number[ground_pts], return_counts=True)
print('Ground Point Return Number distribution:')
for r, c in zip(bins, counts):
print('{}:{}'.format(r, c))
print('min: ', fh.header.min) # x、y、z 的最小值
print('max: ', fh.header.max) # x、y、z 的最大值
print(np.array(las.xyz))
Points from Header: 57185
<LasData(1.2, point fmt: <PointFormat(2, 0 bytes of extra dims)>, 57185 points, 2 vlrs)>
Points from data: 57185
Ground Point Return Number distribution:
min: [-3.79119968 -6.34900093 -0.05 ]
max: [ 9.53839999 12.90089989 0.05 ]
- 点云格式转换:las->pcd
# 适用于laspy<2.0.0的版本
def getCloud():
file = r"./data/10层3号切片抽稀.las"
f = File(file, mode='r')
inFile = np.vstack((f.x, f.y, f.z, f.intensity)).transpose()
cloud = pcl.PointCloud_PointXYZI()
cloud.from_array(np.array(inFile, dtype=np.float32))
f.close()
return cloud
# 保存为pcd文件
def save_pcd():
end1 = time.time()
cloud = getCloud()
pcl.save(cloud, r"./data/test.pcd")
end2 = time.time()
print("las2pcd 耗时:%.2f秒" % (end2 - end1))
print('-------endl----------')